<template>
  <div>
    <div
      style="
        font-size: 16px;
        font-weight: 500;
        color: #1d2129;
        margin-bottom: 16px;
      "
    >
      校园足球数据
    </div>

    <div style="display: flex">
      <div style="width: 25%; border-right: 2px solid #e8e8e8; padding: 0 10px">
        <div style="display: flex">
          <div>
            <div style="font-size: 26px; color: #41b776">34,201</div>
            <div style="font-size: 12px">布局城市总数量（个）</div>
          </div>
        </div>

        <div
          style="
            margin-top: 50px;
            height: 280px;
            width: 100%;
            background: #f7f8fa;
            padding-top: 20px;
          "
        >
          <div style="font-size: 14px; color: #0f0f0f; margin-left: 10%">
            布局城市（个）
          </div>
          <div
            style="
              float: left;
              width: 40%;
              height: 130px;
              background: #e8f3ff;
              margin-left: 20%;
              margin-top: 65px;
              overflow: hidden;
            "
          ></div>
          <div
            ref="footballChart1"
            style="width: 100%; height: 250px; margin-top: 10px"
          ></div>
        </div>
        <div style="float: left; margin-top: -180px; margin-left: 55%">
          <div
            style="
              height: 65px;
              border-left: 20px solid #4e88f5;
              line-height: 55px;
              padding-left: 10px;
              overflow: hidden;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">国家级</span>
            (60%)
          </div>
          <div
            style="
              height: 65px;
              border-left: 20px solid #eeb74a;
              line-height: 55px;
              margin-top: 2px;
              padding-left: 10px;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">省级</span>
            (60%)
          </div>
        </div>
      </div>
      <div style="width: 25%; border-right: 2px solid #e8e8e8; padding: 0 10px">
        <div style="display: flex">
          <div>
            <div style="font-size: 26px; color: #41b776">34,201</div>
            <div style="font-size: 12px">定点学校总数（所）</div>
          </div>
        </div>

        <div
          style="
            margin-top: 50px;
            height: 280px;
            width: 100%;
            background: #f7f8fa;
            padding-top: 20px;
          "
        >
          <div style="font-size: 14px; color: #0f0f0f; margin-left: 10%">
            场馆开放数量占比
          </div>
          <div
            style="
              float: left;
              width: 40%;
              height: 130px;
              background: #e8f3ff;
              margin-left: 20%;
              margin-top: 65px;
              overflow: hidden;
            "
          ></div>
          <div
            ref="footballChart2"
            style="width: 100%; height: 250px; margin-top: 10px"
          ></div>
        </div>
        <div style="float: left; margin-top: -180px; margin-left: 55%">
          <div
            style="
              height: 65px;
              border-left: 20px solid #4e88f5;
              line-height: 55px;
              padding-left: 10px;
              overflow: hidden;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">每天开放 600</span>
            (60%)
          </div>
          <div
            style="
              height: 65px;
              border-left: 20px solid #eeb74a;
              line-height: 55px;
              margin-top: 2px;
              padding-left: 10px;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">每天开放 600</span>
            (60%)
          </div>
        </div>
      </div>
      <div style="width: 25%; border-right: 2px solid #e8e8e8; padding: 0 10px">
        <div style="display: flex">
          <div>
            <div style="font-size: 26px; color: #41b776">34,201</div>
            <div style="font-size: 12px">总经费投入（万元）</div>
          </div>
        </div>

        <div
          style="
            margin-top: 50px;
            height: 280px;
            width: 100%;
            background: #f7f8fa;
            padding-top: 20px;
          "
        >
          <div style="font-size: 14px; color: #0f0f0f; margin-left: 10%">
            场馆开放数量占比
          </div>
          <div
            style="
              float: left;
              width: 40%;
              height: 130px;
              background: #e8f3ff;
              margin-left: 20%;
              margin-top: 65px;
              overflow: hidden;
            "
          ></div>
          <div
            ref="footballChart3"
            style="width: 100%; height: 250px; margin-top: 10px"
          ></div>
        </div>
        <div style="float: left; margin-top: -180px; margin-left: 55%">
          <div
            style="
              height: 65px;
              border-left: 20px solid #4e88f5;
              line-height: 55px;
              padding-left: 10px;
              overflow: hidden;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">每天开放 600</span>
            (60%)
          </div>
          <div
            style="
              height: 65px;
              border-left: 20px solid #eeb74a;
              line-height: 55px;
              margin-top: 2px;
              padding-left: 10px;
              font-size: 12px;
            "
          >
            <span style="color: #4e5969">每天开放 600</span>
            (60%)
          </div>
        </div>
      </div>
      <div style="width: 25%; padding: 0 10px">
        <div style="display: flex; justify-content: space-between">
          <div style="width: 50%">
            <div style="font-size: 26px; color: #41b776">34,201</div>
            <div style="font-size: 12px">布局城市总数量（个）</div>
          </div>
          <div style="width: 50%">
            <div style="font-size: 26px">34,201</div>
            <div style="font-size: 12px">布局城市总数量（个）</div>
          </div>
        </div>
        <div style="width: 100%">
          <div ref="footballChart4" style="width: 100%; height: 290px;"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "SchoolType",
  data() {
    return {
      chartInstance: null
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    datalist() {
      // 基于准备好的dom，初始化echarts实例
      this.footballChart1 = echarts.init(this.$refs.footballChart1);
      this.footballChart2 = echarts.init(this.$refs.footballChart2);
      this.footballChart3 = echarts.init(this.$refs.footballChart3);
      this.footballChart4 = echarts.init(this.$refs.footballChart4);
      // 指定图表的配置项和数据
      const option1 = {
        //鼠标移入显示文字
        tooltip: {
          trigger: "item",
          formatter: "{a}:{b}:({d}%)"
        },

        //颜色设置
        color: ["#EEB74A", "#4E88F5"],
        series: [
          {
            name: "访问来源",
            type: "pie",
            selectedMode: "single",
            radius: [0, "50%"], //饼图大小设置
            center: ["20%", "48%"], // 距离左边，距离上边距离
            //数据文字内部展示
            label: {
              normal: {
                formatter: "{d}%",
                position: "inner",
                color: "#fff"
              }
            },
            //中间的白边设置
            itemStyle: {
              // 此配置
              normal: {
                borderWidth: 4,
                borderColor: "#fff"
              }
            },
            data: [
              {
                value: 38.3,
                name: "每天开放"
              },
              {
                value: 41.6,
                name: "节假日开放"
              }
            ]
          }
        ]
      };
      const option2 = {
        color: ["#4E88F5"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            crossStyle: {
              color: "#41B776"
            }
          }
        },

        xAxis: [
          {
            type: "category",
            data: ["体育部门办", "教育部门办", "体教合办"],
            axisPointer: {
              type: "shadow"
            }
          }
        ],
        yAxis: [
          {
            type: "value",

            min: 0,
            max: 1000,
            interval: 200,
            axisLabel: {
              formatter: "{value} "
            }
          }
        ],
        series: [
          {
            name: "Evaporation",
            type: "bar",
            tooltip: {
              valueFormatter: function(value) {
                return value;
              }
            },
            data: [20, 49, 70]
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      this.footballChart1.setOption(option1);
      this.footballChart2.setOption(option1);
      this.footballChart3.setOption(option1);
      this.footballChart4.setOption(option2);
      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          this.footballChart1.resize();
          this.footballChart2.resize();
          this.footballChart3.resize();
          this.footballChart4.resize();
        }
      });
      // ro.observe(this.$refs.Chart1);
      ro.observe(this.$refs.footballChart1);
      ro.observe(this.$refs.footballChart2);
      ro.observe(this.$refs.footballChart3);
      ro.observe(this.$refs.footballChart4);
    }
  }
};
</script>

<style scoped>
.dianidan {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  margin-top: 3px;
}
</style>
